<?php
//plugin select2
$baseUrl = Yii::app()->theme->baseUrl;
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile($baseUrl . '/plugins/select2/select2.js');
$cs->registerScriptFile($baseUrl . '/plugins/select2/select2_locale_es.js');
$cs->registerCssFile($baseUrl . '/plugins/select2/select2.css');
$cs->registerCssFile($baseUrl . '/plugins/select2/select2-bootstrap.css');
Util::tsRegisterAssetJs('form_wizard.js');
?>
<div class="row-fluid" id="dv_contacto">
    <?php
    $form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(
        'id' => 'contacto-form',
        'type' => 'horizontal',
        'enableAjaxValidation' => true,
        'clientOptions' => array('validateOnSubmit' => true, 'validateOnChange' => false,),
        'enableClientValidation' => false,
    ));
    ?>
    <div class="span8">
        <div class="widget green">
            <div class="widget-title">
                <h4><i class="icon-briefcase"></i> <?php echo Yii::t('AweCrud.app', $model->isNewRecord ? 'Create' : 'Update') . ' ' . Contacto::label(); ?></h4>
                <span class="tools">
                    <a href="javascript:;" class="icon-chevron-down"></a>
                    <!--a href="javascript:;" class="icon-remove"></a-->
                </span>
            </div>
            <div class="widget-body">
                <div class="row-fluid">
                    <p class="note">
                        <?php echo Yii::t('AweCrud.app', 'Fields with') ?> <span class="required">*</span>
                        <?php echo Yii::t('AweCrud.app', 'are required') ?>.    
                    </p>
                    <?php echo $form->dropDownList($model, 'titulo', array('Sr.' => 'Sr.', 'Srta.' => 'Srta.', 'Sra.' => 'Sra.'), array('empty' => '(Ninguno)', 'class' => 'span2 fix')) ?>

                    <?php echo $form->textField($model, 'nombre', array('maxlength' => 32, 'class' => 'span5', 'placeholder' => "Nombre")) ?>

                    <?php echo $form->textField($model, 'apellido', array('maxlength' => 32, 'class' => 'span5', 'placeholder' => "Apellido*")) ?>

                    <?php echo $form->error($model, 'apellido'); ?>

                    <?php echo $form->hiddenField($model, 'id') ?>

                    <div class="space20"></div>
                    <div class="control-group ">
                        <label class="control-label" for="Contacto_cuenta_id">Cuenta</label>
                        <div class="controls">

                            <?php
                            $htmlOptions = array('class' => "span6");
                            if ($model->cuenta_id) {
                                $model_cuenta = Cuenta::model()->findByPk($model->cuenta_id);
                                $htmlOptions = array_merge($htmlOptions, array(
                                    'selected-text' => $model_cuenta->documento . ' ' . $model_cuenta->nombre
                                ));
                            }
                            echo $form->hiddenField($model, 'cuenta_id', $htmlOptions);
                            ?>
                            <span class="help-inline error" id="Contacto_cuenta_id_em_" style="display: none"></span>
                        </div>
                    </div>
                    <?php echo $form->textFieldRow($model, 'documento', array('maxlength' => 20, 'data-mask' => '0000000000', 'class' => 'span6')) ?>
                    <?php echo $form->textFieldRow($model, 'cargo', array('maxlength' => 64, 'class' => 'span6')) ?>
                    <?php echo $form->textFieldRow($model, 'departamento', array('maxlength' => 64, 'class' => 'span6')) ?>
                    <?php echo $form->textAreaRow($model, 'descripcion', array('rows' => 3, 'class' => 'span10')) ?>

                    <!--</div>-->

                    <div class="form-actions">
                        <?php
//                        $this->widget('bootstrap.widgets.TbButton', array(
////                                        'buttonType' => 'submit',
//                            'type' => 'success',
//                            'icon' => 'ok',
//                            'label' => $model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),
//                            'htmlOptions' => array(
//                                'onClick' => 'js:save("#contacto-form")')
//                        ));
                        ?>
                        <?php
//                        $this->widget('bootstrap.widgets.TbButton', array(
//                            'icon' => 'remove',
//                            'label' => Yii::t('AweCrud.app', 'Cancel'),
//                            'htmlOptions' => array('onclick' => 'javascript:history.go(-1)')
//                        ));
                        ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="span4">
        <?php if ($grupos): ?>
            <div class="widget green">
                <div class="widget-title">
                    <h4><i class="icon-archive"></i> Grupos</h4>
                    <span class="tools">
                        <a href="javascript:;" class="icon-chevron-down"></a>
                        <!--a href="javascript:;" class="icon-remove"></a-->
                    </span>
                </div>
                <div class="widget-body">
                    <div class="check-box-list">
                        <?php echo $form->checkBoxList($model, 'grupos', CHtml::listData($grupos, 'id', 'nombre'), array_map('AweHtml::getPrimaryKey', $model->grupos)); ?>
                    </div>
                </div>
            </div>
        <?php endif; ?>

        <div class="widget">
            <div class="widget-title">
                <h4><i class="icon-lock"></i> Permisos</h4>
                <span class="tools">
                    <a href="javascript:;" class="icon-chevron-down"></a>
                    <!--a href="javascript:;" class="icon-remove"></a-->
                </span>
            </div>
            <div class="widget-body permisos">
                <?php echo $form->dropDownListRow($model, 'owner_id', CHtml::listData(Yii::app()->user->um->listUsers(), 'iduser', 'username'), array('empty' => '- Seleccione -', 'class' => 'span12 fix')) ?>
                <div class="radio-list">
                    <?php echo $form->radioButtonListRow($model, 'permisos', $model->permisosOpciones) ?>
                </div>
            </div>
        </div>
    </div>
    
</div>
<!--<div class="row-fluid panel" id="dv_btn_finalizar" <?php echo $model->isNewRecord ? 'hidden' : '' ?>>
    <div class="offset10">
        <a id="btn_finalizar" class="btn  btn-info" type="button" <?php // echo!$model->isNewRecord ? 'href="' . Yii::app()->createUrl('crm/contacto/view', array('id' => $model->id)) . '"' : ''   ?>> Finalizar </a>
    </div>
    <div class="space15"></div>
</div>-->
<div id="tab_medios">
    <div class="row-fluid panel" id="dv_direccion" <?php // echo $model->isNewRecord ? 'hidden' : ''   ?>>
        <?php $this->renderPartial('steps/_direccionContactos', array('model' => $model)) ?>
    </div>
    <div class="row-fluid panel" id="dv_email_telefono" <?php // echo $model->isNewRecord ? 'hidden' : ''   ?>>
        <div class="span6">
            <?php $this->renderPartial('steps/_emailContactos', array('model' => $model)) ?>
        </div>
        <div class="span6">
            <?php $this->renderPartial('steps/_telefonoContactos', array('model' => $model)) ?>
        </div> 
    </div>
    <div class="row-fluid panel" id="dv_red_social" <?php // echo $model->isNewRecord ? 'hidden' : ''   ?>>
        <div class="span6">
            <?php $this->renderPartial('steps/_redesSociales', array('model' => $model)) ?>
        </div>
    </div>
    <div class="form-actions-float flotante" style="right: 0; left:initial;">
        <div style="float:right;">
            <a id="btn_finalizar" class="btn btn-large btn-info" type="button" style="<?php echo $model->isNewRecord ? 'display: none' : 'display: inline-block' ?>" href="<?php echo $model->isNewRecord ? '' : $baseUrl . 'crm/contacto/view/id/' . $model->id ?>"><i class="icon-signout icon-white"></i> Finalizar </a>
            <?php
            $this->widget('bootstrap.widgets.TbButton', array(
//                                        'buttonType' => 'submit',
                'type' => 'success',
                'icon' => 'ok',
                'label' => $model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),
                'htmlOptions' => array(
                    'style' => $model->isNewRecord ? 'display: inline-block' : 'display: none',
                    'id' => 'btn_crearContacto',
                    'class' => 'btn-large',
                    'onClick' => 'js:save("#contacto-form")')
            ));
            ?>
            <?php
            $this->widget('bootstrap.widgets.TbButton', array(
                'icon' => 'remove',
                'label' => Yii::t('AweCrud.app', 'Cancel'),
                'htmlOptions' => array(
                    'class' => 'btn-large',
                    'onclick' => 'javascript:history.go(-1)')
            ));
            ?>
        </div>
        <!--<div class="offset10">-->

        <!--</div>-->
        <!--<div class="space15"></div>-->
    </div>
    <div class="space15"></div>
    <!--</div>-->
</div>
<?php $this->endWidget(); ?>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places"></script>
<script src="<?php echo Yii::app()->theme->baseUrl; ?>/js/gmaps.js"></script>